#ifndef _2_94_H
#define _2_94_H

typedef unsigned float_bits;

/* Compute 2*f. If f is NaN, then return f. */
float_bits float_twice(float_bits f){
    float_bits sign = f >> 31;
    float_bits exp  = f >> 23 & 0xFF;
    float_bits frac = f       & 0x7FFFFF;

    float_bits result = f;
    bool isNaN = (exp == 0xFF) && (frac != 0);
    bool isBiggest = (exp == 0xFF) && (frac == 0);

    /* if isNaN == true, break; */
    isNaN ||
    /* if isBiggest == true, break */
    isBiggest ||
    /* if exp != 0, then exp += 1; */
    ((exp != 0) && (result = sign << 31 | (exp + 1) << 23 | frac)) ||
    /* if exp == 0 && frac >> 22 == 0, then frac = (frac << 1) & 0x7FFFFF */
    (((frac >> 22) == 0) && (result = sign << 31 | exp << 23 | ((frac << 1) & 0x7FFFFF))) ||
    /* if exp == 0 && frac >> 22 == 1, then exp += 1, frac = (frac << 1) & 0x7FFFFF */
    (result = sign << 31 | (exp + 1) << 23 | ((frac << 1) & 0x7FFFFF));

    return result;
}


#endif // _2_94_H

